<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\Application;
use Laravel\Lumen\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     * @var array
     */
    protected $command = [
        'App\Console\Commands\UserCommand',//用户信息同步es和redis
        'App\Console\Commands\FetchVideoM3U8URL',
        'App\Console\Commands\Test',
    ];

    //定时任务
    protected $crontab = [
        'App\Console\Commands\UserSignSchedule',//用户签到-定时任务
        'App\Console\Commands\FetchVideoCommand',//从互联网上拉取视频
    ];

    public function __construct(Application $app)
    {
        parent::__construct($app);
        $this->commands = array_merge($this->crontab,$this->command);
    }

    /**
     * Define the application's command schedule.
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * 注意：常驻进程时，出现找不到命令 需要清楚应用缓存 php artisan cache:clear 一次测试链接rabbitmq客户端时出现过此问题
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        //用户签到数据每天入库
//        $schedule->command('UserSignSchedule:addMysql')->daily()->withoutOverlapping()->runInBackground();
//        $schedule->command('test a')->everyMinute()->withoutOverlapping()->runInBackground();
//        $schedule->command('FetchVideoFromInternet')->cron('* 21-9/3 * * *')->withoutOverlapping()->runInBackground();
//        $schedule->command('FetchVideoFromInternet')->cron('41 19 * * *')->withoutOverlapping()->runInBackground();
    }
}
